package com.itcast.activiti.controller;


import cn.itcast.ic.common.bean.Response;
import com.itcast.activiti.entity.ApproveField;
import com.itcast.activiti.service.IApproveFieldService;
import com.itcast.activiti.utils.ItcastPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 变量表  前端控制器
 * </p>
 *
 * @author itcast
 * @since 2021-03-02
 */
@RestController
@RequestMapping("/field")
public class ApproveFieldController {
    @Autowired
    private IApproveFieldService iApproveFieldService;

    @PostMapping(value = "/list")
    public Response listApproveDefinitionPage(@RequestBody ItcastPage itcastPage) {
        return Response.success(iApproveFieldService.listApproveFieldPage(itcastPage));
    }

    @GetMapping(value = "/list")
    public Response listApproveDefinition() {
        return Response.success(iApproveFieldService.listApproveField());
    }

    @GetMapping(path = "/{id}")
    public Response getApproveField(@PathVariable("id") Integer id) {
        return Response.success(iApproveFieldService.getApproveField(id));
    }

    @PostMapping(value = "/add")
    public Response addApproveField(@RequestBody ApproveField approveField) {
        return Response.success(iApproveFieldService.addApproveField(approveField));
    }

    @PostMapping(value = "/edit")
    public Response editApproveField(@RequestBody ApproveField approveField) {
        return Response.success(iApproveFieldService.editApproveField(approveField));
    }

    @DeleteMapping(path = "/del/{id}")
    public Response delApproveField(@PathVariable("id") Integer id, @RequestParam(required = false) String createdBy) {
        return Response.success(iApproveFieldService.delApproveField(id, createdBy));
    }
}

